Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: SARIF Output Support #192

Merged
merged 11 commits into from
May 2, 2023
Merged

feat: SARIF Output Support #192

merged 11 commits into from
May 2, 2023

Conversation

chtzvt
Copy link
Contributor

@chtzvt chtzvt commented Apr 28, 2023

What's being changed?

This pull request adds support for SARIF output to Legitify.

Is this PR related to an existing issue?

This PR closes #11.

Check off the following:

  • This PR follows the CONTRIBUTION.md guidelines
  • I have self-reviewed my changes before submitting the PR

Additional Notes

An example of the SARIF output produced by this feature can be seen here. Microsoft provides this nifty tool if you'd like to parse/visualize the results.

This PR introduces a dependency on github.com/owenrumney/go-sarif/v2/sarif.

With ❤️ from @XpiritBV.

@chtzvt chtzvt requested a review from a team as a code owner April 28, 2023 03:30
@chtzvt chtzvt changed the title SARIF Output Support feat: SARIF Output Support Apr 28, 2023
@chtzvt
Copy link
Contributor Author

chtzvt commented Apr 28, 2023

The last few commits fix and improve the output's SARIF spec conformance.

Here are some screenshots of how the results look in the GitHub Security Center:

Screenshot 2023-04-28 at 12 07 00

Screenshot 2023-04-28 at 12 07 20

I'm also working on an update to the action.yml for Legitify to upload the SARIF results (see the sarif-action-support branch).

A simple demonstration is available at https://github.com/XpiritUSA/test-legitify.

go.sum Outdated Show resolved Hide resolved
internal/outputer/formatter/formatter_sarif.go Outdated Show resolved Hide resolved
internal/outputer/formatter/formatter_sarif.go Outdated Show resolved Hide resolved
internal/outputer/formatter/formatter_sarif.go Outdated Show resolved Hide resolved
internal/outputer/formatter/formatter_sarif.go Outdated Show resolved Hide resolved
internal/outputer/formatter/formatter_sarif.go Outdated Show resolved Hide resolved
internal/outputer/formatter/policies_content.go Outdated Show resolved Hide resolved
internal/outputer/formatter/policies_content.go Outdated Show resolved Hide resolved
@gal-legit
Copy link
Contributor

@chtzvt thanks a lot for this PR! your effort is really appreciated!
Most of my comments are pretty minor. let me know if you have any questions.

It seems that the tests are failing.
one issue is the Aux being nil (see the comment on that), but another issue is that output_format_test.go should have a case for sarif now. Ideally we'll have a thorough tests for that output, but for now would be great to add a "TODO add dedicated tests for sarif output" there

@chtzvt
Copy link
Contributor Author

chtzvt commented May 1, 2023

@gal-legit Thanks for your feedback!

I've implemented the changes you've requested, as well as working tests that validate Legitify's SARIF output against the SARIF specification JSON schema.

@gal-legit
Copy link
Contributor

@chtzvt
Thanks for all your effort! Also, I love the sarif test you added!
We'll add support for code-scanning results in legitify's action based shortly :)

@gal-legit gal-legit merged commit 468aeb2 into Legit-Labs:main May 2, 2023
@chtzvt
Copy link
Contributor Author

chtzvt commented May 2, 2023

Fantastic! Glad to see it ship.

I started work on the SARIF action in the sarif-action-support branch. If that looks like the direction you'd want to go with, I can open another PR.

@gal-legit
Copy link
Contributor

@chtzvt
Ahh, I just realized that I missed the fact that you mentioned that in your original comment too.
I already implemented it today actually (see gofri/sarif-action branch).
Sorry for not alerting before.

We don't want the SARIF output to replace the existing output, but rather to come on top of it.
TBH that was the original motive for implementing the convert command in the first place.

Anyway, I'd love to hear your thoughts on this.
I'm gonna test the action to make sure that everything works as expected and I'll open a PR then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support SARIF output format
2 participants